﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace RpgLibrary
{
    public static class RpgConstants
    {
        public const int TileWidth = 64;
        public const int TileHeight = 64;

        public const int ScreenWidth = 1280;//1920;
        public const int ScreenHeight = 720;//1080;
        public const bool FullScreen = false;
        public const int WalkDirections = 8;
        
        static string basePath = string.Empty;
        static string gamePath = string.Empty;
        static string classPath = string.Empty;
        static string itemPath = string.Empty;
        static string chestPath = string.Empty;
        static string keyPath = string.Empty;
        static string skillPath = string.Empty;
        static string armorPath = string.Empty;
        static string shieldPath = string.Empty;
        static string weaponPath = string.Empty;
        static string gameFilePath = string.Empty;

        public static string BasePath
        {
            get
            {
                return basePath;
            }
            set
            {
                if (!Directory.Exists(value))
                    throw new Exception("The value assigned to the BasePath variable must be an existing directory");

                basePath = value;
            }
        }

        public static string GamePath
        {
            get
            {
                if (String.IsNullOrEmpty(gamePath))
                {
                    if (String.IsNullOrEmpty(BasePath))
                        throw new Exception("Trying to access GamePath when no BasePath has been set");

                    gamePath = Path.Combine(BasePath, "Game");
                }

                return gamePath;
            }
        }

        public static string ClassPath
        {
            get
            {
                if (String.IsNullOrEmpty(classPath))
                    classPath = Path.Combine(GamePath, "Classes");

                return classPath;
            }
        }


        public static string ItemPath
        {
            get
            {
                if (String.IsNullOrEmpty(itemPath))
                    itemPath = Path.Combine(GamePath, "Items");

                return itemPath;
            }
        }

        public static string ChestPath
        {
            get
            {
                if (String.IsNullOrEmpty(chestPath))
                    chestPath = Path.Combine(GamePath, "Chests");

                return chestPath;
            }
        }

        public static string KeyPath
        {
            get
            {
                if (String.IsNullOrEmpty(keyPath))
                    keyPath = Path.Combine(GamePath, "Keys");

                return keyPath;
            }
        }

        public static string SkillPath
        {
            get
            {
                if (String.IsNullOrEmpty(skillPath))
                    skillPath = Path.Combine(GamePath, "Skills");

                return skillPath;
            }
        }

        public static string ArmorPath
        {
            get
            {
                if (String.IsNullOrEmpty(armorPath))
                    armorPath = Path.Combine(ItemPath, "Armor");

                return armorPath;
            }
        }

        public static string ShieldPath
        {
            get
            {
                if (String.IsNullOrEmpty(shieldPath))
                    shieldPath = Path.Combine(ItemPath, "Shield");

                return shieldPath;
            }
        }

        public static string WeaponPath
        {
            get
            {
                if (String.IsNullOrEmpty(weaponPath))
                    weaponPath = Path.Combine(ItemPath, "Weapon");

                return weaponPath;
            }
        }

        public static string GameFilePath
        {
            get
            {
                if (String.IsNullOrEmpty(gameFilePath))
                    gameFilePath = Path.Combine(GamePath, "Game.xml");

                return gameFilePath;
            }
        }
    }
}
